package com.tql.mall.payment.controller;

import com.tql.mall.common.constant.ComConstant;
import com.tql.mall.payment.service.PaymentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: tyk
 * @Date: 2023/5/27 17:01
 * @Description:
 */
@Controller
@RequestMapping("api/payment/auth")
@Api(description = "支付管理")
public class PaymentController {

    @Autowired
    private PaymentService paymentService;

    /**
     * 支付界面
     */
    @GetMapping({"alipay/submit/{orderId}", "weixin/submit/{orderId}"})
    @ApiOperation("虚拟支付")
    public void doPay(@PathVariable Long orderId, HttpServletResponse resp) throws IOException {
        Boolean flag = paymentService.doPay(orderId);
        resp.sendRedirect(ComConstant.PAY_RESULT_DIR);
    }


}
